﻿using System;
using System.IO;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Navigation;
using WpfHero;

namespace WpfHeroTutorial
{
	public partial class HorizontalScroller
	{
	    private WHEngine engine;

		public HorizontalScroller()
		{
            DataContextChanged += delegate { engine = (WHEngine)DataContext; };
            this.InitializeComponent();
		}

        public void Start()
        {
            App.DoEvents();
            DoubleAnimation da = new DoubleAnimation
                                     {
                                         From = 0,
                                         To = (grid.ActualWidth * -1) + stackPanel.Margin.Left,
                                         Duration = new Duration(engine.EndOfSong)
                                     };
            stackPanel.RenderTransform = new TranslateTransform();
            stackPanel.RenderTransform.BeginAnimation(TranslateTransform.XProperty, da);
        }
	}
}